package cn.com.yusys.yusp.admin.web.rest;

import cn.com.yusys.yusp.admin.domain.AdminSmLookupType;
import cn.com.yusys.yusp.admin.service.AdminSmLookupTypeService;
import cn.com.yusys.yusp.commons.service.CommonService;
import cn.com.yusys.yusp.commons.web.rest.CommonResource;
import cn.com.yusys.yusp.commons.web.rest.dto.ResultDto;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.net.URISyntaxException;
import java.util.List;


/**
 * @项目名称: yusp-admin
 * @类名称: AdminSmLookupTypeResource
 * @类描述: 数据字典类别目录
 * @功能描述: 
 * @创建人: liaoxd@yusys.com.cn
 * @创建时间: 2017-12-27 17:50
 * @修改备注: 
 * @修改记录: 修改时间    修改人员    修改原因
 * -------------------------------------------------------------
 * @version 1.0.0
 * @Copyright (c) 2017宇信科技-版权所有
 */
@RestController
@RequestMapping("/api/adminsmlookuptype")
public class AdminSmLookupTypeResource extends CommonResource<AdminSmLookupType, String> {

	@Autowired
	private AdminSmLookupTypeService adminSmLookupTypeService;

	private final Logger log = LoggerFactory.getLogger(AdminSmLookupTypeResource.class);

	@Override
	protected CommonService getCommonService() {
		// TODO Auto-generated method stub
		return this.adminSmLookupTypeService;
	}

	/**
	* @方法名称: deleteMult
	* @方法描述: 多个删除
	* @参数与返回说明: 
	* @算法描述: 
	*/
	@PostMapping("/deletes")
	public ResultDto<Integer> deleteMult(
			@ApiParam(value = "Object Of PK id", required = true) @RequestBody List<String> ids) {
		log.debug("REST request to delete Object : {}", ids);
		ResultDto<Integer> resultDto = new ResultDto<>();
		for (String s : ids) {
			this.adminSmLookupTypeService.deleteByTypeId(s);
		}
		resultDto.setMessage("删除类别目录下的字典内容！");
		resultDto.setData(ids.size());
		return resultDto;

	}

	/**
	* @方法名称: updateSelective
	* @方法描述:修改接口 
	* @参数与返回说明: 
	* @算法描述: 
	*/
	@PostMapping("/updates")
	public ResultDto<Integer> updateSelective(@ApiParam(value = "Object", required = true) @RequestBody AdminSmLookupType t)
			throws URISyntaxException {
		log.debug("REST request to update Object : {}", t);

		int result = getCommonService().updateSelective(t);

		return new ResultDto<Integer>(result);
	}
	
	/**
	* @方法名称: getLookupTypeList
	* @方法描述: 全量查询
	* @参数与返回说明: 
	* @算法描述: 
	*/
	@GetMapping("/list")
	public ResultDto<List<AdminSmLookupType>> getLookupTypeList() {
		log.debug("REST request to get Object : {}");
		List<AdminSmLookupType> list = this.adminSmLookupTypeService.getTypeList();

		return new ResultDto<List<AdminSmLookupType>>(list.size(),list);

	}

}
